<html>
<head><meta charset="utf-8"><title>canonical deref #53843 · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html">canonical deref #53843</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="133275001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133275001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133275001">(Sep 03 2018 at 19:11)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> </p>
<p>you online?</p>



<a name="133275122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133275122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133275122">(Sep 03 2018 at 19:15)</a>:</h4>
<p>I had some thoughts about <a href="https://github.com/rust-lang/rust/issues/53843" target="_blank" title="https://github.com/rust-lang/rust/issues/53843">#53843</a></p>
<p>The issue there is that autoderef does not resolve nested obligations while evaluating the chain.</p>
<p>The problem is that autoderef runs in a "probe" context from which the fulfillcx can't be accessed. I think the solution would be to move autoderef to be a canonical query, where <code>autoderef(Γ ⊢ canonical--ty, n)</code> is an <code>(canonical-substs, ty, obligations)</code> triple.</p>



<a name="133275240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133275240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133275240">(Sep 03 2018 at 19:19)</a>:</h4>
<p>The current QueryResult struct does not support returning obligations, so I was wondering whether the best way of handling this would be by having a separate "probe" and "confirm" stages, where only the confirm returns obligations.</p>



<a name="133281261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133281261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133281261">(Sep 03 2018 at 22:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Could you look at <a href="https://github.com/rust-lang/rust/pull/53778" target="_blank" title="https://github.com/rust-lang/rust/pull/53778">https://github.com/rust-lang/rust/pull/53778</a> sooner?<br>
It's a prerequisite for a number of other PRs that need to be done until beta (which is pretty soon).</p>



<a name="133308623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133308623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133308623">(Sep 04 2018 at 12:45)</a>:</h4>
<p><span class="user-mention" data-user-id="126804">@Ariel Ben-Yehuda</span> hmm, the goal with queries is not to <strong>have</strong> to return obligations, but instead to "fully process" the obligations in situ, and just return the results. Does that not work in this case — perhaps because of ambiguity?</p>



<a name="133308627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133308627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133308627">(Sep 04 2018 at 12:45)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> (sure)</p>



<a name="133326683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133326683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133326683">(Sep 04 2018 at 18:10)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> </p>
<p>Sure. The intent of autoderef is that, say, when you want to deref <code>Vec&lt;$0&gt;</code>, you will get <code>[$0]</code> (the ref type is "implicit"). If that deref impl had obligations on <code>$0</code> (I can't seem to find any), they would also need to be processed.</p>



<a name="133326905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133326905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133326905">(Sep 04 2018 at 18:14)</a>:</h4>
<p>Or if you autoderef <code>Pin&lt;Option&lt;$0&gt;&gt;</code>, you get <code>Option&lt;$0&gt; where $0: Unpin</code></p>
<p>Or in canonical language, that would be something like <code>dest = Option&lt;$α&gt;, substs = [$0 &lt;- $α], obligations = [$α: Unpin]</code> where α is the "canonical output" type.</p>



<a name="133328097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133328097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133328097">(Sep 04 2018 at 18:35)</a>:</h4>
<p>Hmm. Yes, of course. So we want to do some sort of "shallow" testing. Well, in any case, it should be possible to create a canonical query result that includes obligations without any great difficulty.</p>



<a name="133328172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133328172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133328172">(Sep 04 2018 at 18:36)</a>:</h4>
<blockquote>
<p>The current QueryResult struct does not support returning obligations, so I was wondering whether the best way of handling this would be by having a separate "probe" and "confirm" stages, where only the confirm returns obligations.</p>
</blockquote>
<p>I'm re-reading this question of yours :)</p>



<a name="133328216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133328216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133328216">(Sep 04 2018 at 18:37)</a>:</h4>
<p>I'm not sure if the probe/confirm is worth it, trying to think that over. It seems like you could just have a <code>QueryResult&lt;AutoDerefResult&gt;</code> where the <code>AutoDerefResult</code> includes the "deferred" obligations that we do not evaluate</p>



<a name="133328249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/canonical%20deref%20%2353843/near/133328249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/canonical.20deref.20.2353843.html#133328249">(Sep 04 2018 at 18:38)</a>:</h4>
<p>this is going to be a fun thing to figure out in chalk :P</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>